using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace usm.SolDev.DataBase.DataObjects.Experiment
{
    /// <summary>
    ///     The object which parses experiments
    /// </summary>
    public class Experiment : DataObject
    {
        #region Private data
        private bool isValid;

        // These are components of an experiment
        private List<GlobalVariable> globalVariables;
        private List<StatisticInfo> statisticInfos;
        private List<Transaction> transactions;
        private List<Entity> entities;
        #endregion

        #region Constructors
        /// <summary>
        ///     Default constructor
        /// </summary>
        public Experiment () {}

        /// <summary>
        ///     Initialization and parser constructor
        /// </summary>
        /// <param name="drgLine"></param>
        public Experiment (string drgLine)
        {
            #region Match the line to a experiment
            Match matchResult = null;
             matchResult = Regex.Match(drgLine, @"(?i)\s*#\s*");
            if (matchResult != null && matchResult.Length > 0)
            {
                isValid = true;
            }



            #endregion
        }
        #endregion

        #region Public properties
        /// <summary>
        ///     Indicates if the passed string has matched expected format
        /// and the contained data is valid (read/only property)
        /// </summary>
        public bool IsValid
        {
            get { return isValid; }
        }

        /// <summary>
        ///     A list of available global variables in the experiment
        /// </summary>
        public List<GlobalVariable> GlobalVariables
        {
            get 
            {
                if (globalVariables == null)
                {
                    globalVariables = new List<GlobalVariable>();
                }

                return globalVariables;
            }

            set { globalVariables = value; }
        }

        /// <summary>
        ///     A list of available statistic information in the experiment
        /// </summary>
        public List<StatisticInfo> StatisticInfos
        {
            get
            {
                if (statisticInfos == null)
                {
                    statisticInfos = new List<StatisticInfo>();
                }

                return statisticInfos;
            }

            set { statisticInfos = value; }
        }

        /// <summary>
        ///     A list of available transactions in the experiment
        /// </summary>
        public List<Transaction> Transactions
        {
            get
            {
                if (transactions == null)
                {
                    transactions = new List<Transaction>();
                }

                return transactions;
            }

            set { transactions = value; }
        }
        #endregion
    }
}
